﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MiniQQWebApi.Models.EF;

namespace MiniQQWebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class T001UsersController : ControllerBase
    {
        private MiniQQ2020Context db = new MiniQQ2020Context();
        /// <summary>
        /// 显示所有记录
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult GetAll()
        {
            var items = db.T001用户表;
            return Ok(items);
        }

        /// <summary>
        /// 根据昵称查询是否存在
        /// </summary>
        /// <param name="nickname"></param>
        /// <returns></returns>
        [HttpGet("nickname/(nickname)")]
        public ActionResult SearchNickName(string nickname)
        {
            var ans = db.T001用户表.Any(m => m.昵称 == nickname);
            return Ok(ans);
        }

        /// <summary>
        /// 查询账号是否存在
        /// </summary>
        /// <param name="nicknumber"></param>
        /// <returns></returns>
        [HttpGet("nicknumber/(nicknumber)")]
        public ActionResult SearchNickNumber(string nicknumber)
        {
            var ans = db.T001用户表.Any(m => m.Qq号 == nicknumber);
            return Ok(ans);
        }
    }
}
